'''
2.给定一个m*n的二维列表,查找一个数是否存在,列表有下列特性
    每一行的列表从左到右已经排序好
    每一行第一个数比上一行最后一个数大
'''

def erfe_sort(li,target):
    start = 0
    end = len(li) - 1

    while start <= end:
        mid = (start + end) // 2
        if li[mid] > target:
                end = mid - 1

        elif li[mid] < target:
                start = mid + 1

        else:
            return mid
    return None

def find(li2,val):

    n = len(li2[0])
    li_all =[]
    for li_n in li2:
        li_all.extend(li_n)
    print(li_all)
    id = erfe_sort(li_all, val)
    print(id)
    id_m = id // n
    id_n = id % n
    print(f'要找的数字在第{id_m}行,{id_n}列')
    return id_m,id_n

li = [
      [1, 3, 5, 7],
      [10,11,16,20],
      [23,30,34,50]
      ]
target = 23
print(find(li,target))
